
toastLog("哈哈");
//初始返回主屏幕
home();
//等待3秒准备点击
sleep(3000);
//找到部落冲突并点击启动
text("部落冲突").findOne().click();
//等待进入游戏
sleep(30 * 1000);
//模拟器分辨率不同，地图过大，缩放拉到中心
//参数分析[0:延迟执行时间,滑动执行时间, [0, 0]：滑动开始坐标, [500, 100]：滑动结束宿坐标
//gestures传入多手势轨迹模拟手指捏合缩放动作

log(device);
// gestures([0, 500, [0, 0], [500, 100]], [0, 500, [300, 1500], [500, 1000]]);
//封装屏幕模拟缩放
//获取这个控件
// var widget = className("android.widget.EditText").findOne();
//获取其中心位置并点击
//   click(widget.bounds().centerX(), widget.bounds().centerY());
// log(widget.bounds().centerX(), widget.bounds().centerY(),center)
//保证部落界面视角高度最高
let delay = 0,
  duration = 500;
for (let i = 0; i < 2; i++) {
  screenScale(delay, duration);
  sleep(3000);
}
function screenScale(delay, duration) {
  //获取设备宽高
  let deviceWidth = device.width;
  let deviceHeight = device.height;
  //需四个点位
  //中心
  let center = [deviceWidth / 2, deviceHeight / 2];
  //中上
  let middleTop = [deviceWidth / 2, deviceHeight / 2 - 50];
  //中下
  let middleBottom = [deviceWidth / 2, deviceHeight / 2 + 50];
  //中左
  let middleLeft = [deviceWidth / 2 - 100, deviceHeight / 2];
  //中右
  let middleRight = [deviceWidth / 2 + 100, deviceHeight / 2];
  gestures(
    [delay, duration, middleTop, center],
    [delay, duration, middleBottom, center],
    [delay, duration, middleLeft, center],
    [delay, duration, middleRight, center]
  );
}
